<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<base href="<%=basePath%>">
	<link href="css/style.css" rel="stylesheet" type="text/css" />
</head>
<body>
    <ul class="forminfo" style="margin-top: 20px;">
    <c:if test="${userRole<=2 }">
     <li><label>所属院系</label>
					<select name="XYDM" class="forminfo_select" id="XYDM" >
						<c:forEach items="${departmentInfoList}" var="departmentInfo">
							<option value="${departmentInfo.XYDM }" <c:if test="${departmentInfo.XYDM == XYDM }">selected</c:if> >${departmentInfo.XYMC }</option>
						</c:forEach>
					</select>
     </li>
     </c:if>
     <c:if test="${userRole > 2 }">
     <li><label>所属院系</label>${ departmentName }</li>
     </c:if>
     <li><label>岗位名称</label><input name="JobName" type="text" class="dfinput" maxlength="15"></li>
     <li><label>岗位说明</label><textarea name="JobIntroduce" class="long_text long_text2" maxlength="40"></textarea></li>
      <li><label>岗位要求</label><textarea name="TechnicalAbilityNeed" class="long_text long_text2" maxlength="40"></textarea></li>
	<li><label>&nbsp;</label><input name="" type="button" class="btn" onclick="submitForm()" value="确认保存"/></li>
    </ul>
</body>
<script type="text/javascript" src="js/jquery-1.7.2.js" ></script>
	<script type="text/javascript" src="js/jquery.tips.js"></script>
	<script type="text/javascript" src="layer/layer.js" ></script>
<script type="text/javascript">
function submitForm() {
	if ($("input[name='JobName']").val() == "") {
		showTips($("input[name='JobName']"), '请填写岗位名称!');
		return false;
	}
	if ($("textarea[name='JobIntroduce']").val() =="") {
		showTips($("textarea[name='JobIntroduce']"), '请填写岗位说明!');
		return false;
	}
	if ($("textarea[name='TechnicalAbilityNeed']").val() == "") {
		showTips($("textarea[name='TechnicalAbilityNeed']"), '请填写岗位要求!');
		return false;
		}
	var userRole = '${userRole}';
	if(userRole <=2){
		 var ele=document.getElementById('XYDM');
	  	var index=ele.selectedIndex;
	 	 var val=ele.options[index].value;
	 	}else{
	 		var val= "";
	 	}
	$.ajax({
		type: "POST",
		url: "jobinfo/jobInfo_save.do",
		data: { XYDM : val,JobName : $("input[name='JobName']").val(),JobIntroduce:$("textarea[name='JobIntroduce']").val(),TechnicalAbilityNeed:$("textarea[name='TechnicalAbilityNeed']").val()},
		async: true,
		dataType: "json",
		success: function(data) {
			if("success" == data.result){
				parent.closeAll();
		}else {
			layer.alert('添加失败!', {
	            skin: 'layer-ext-moon' 
	        });
			}
			}
		})
	}
function showTips(obj,tips) {
	obj.tips({
		side:3,
        msg:tips,
        bg:'#e69138',
        time:2
    });
}
</script>
</html>
